/*   1:    */ package org.jetbrains.jps.model.module.impl;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.util.Condition;
import com.intellij.util.CollectConsumer;
import com.intellij.util.Consumer;
import com.intellij.util.Processor;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.library.JpsLibrary;
import org.jetbrains.jps.model.module.*;

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */ 
/*  22:    */ public abstract class JpsDependenciesEnumeratorBase<Self extends JpsDependenciesEnumerator>
/*  23:    */   implements JpsDependenciesEnumerator
/*  24:    */ {
/*  25:    */   private boolean a;
/*  26:    */   private boolean b;
/*  27:    */   protected boolean myWithoutDepModules;
/*  28:    */   private boolean c;
/*  29:    */   protected boolean myRecursively;
/*  30:    */   protected final Collection<JpsModule> myRootModules;
/*  31:    */   private Condition<JpsDependencyElement> d;
/*  32:    */   
/*  33:    */   protected JpsDependenciesEnumeratorBase(Collection<JpsModule> paramCollection)
/*  34:    */   {
/*  35: 44 */     this.myRootModules = paramCollection;
/*  36:    */   }
/*  37:    */   
/*  38:    */   @NotNull
/*  39:    */   public Self withoutLibraries()
/*  40:    */   {
/*  41: 50 */     this.b = true; JpsDependenciesEnumerator 
/*  42: 51 */       tmp9_6 = self();
/*  43: 51 */     if (tmp9_6 == null) {
/*  44: 51 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "withoutLibraries" }));
/*  45:    */     }
/*  46: 51 */     return tmp9_6;
/*  47:    */   }
/*  48:    */   
/*  49:    */   @NotNull
/*  50:    */   public Self withoutDepModules()
/*  51:    */   {
/*  52: 57 */     this.myWithoutDepModules = true; JpsDependenciesEnumerator 
/*  53: 58 */       tmp9_6 = self();
/*  54: 58 */     if (tmp9_6 == null) {
/*  55: 58 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "withoutDepModules" }));
/*  56:    */     }
/*  57: 58 */     return tmp9_6;
/*  58:    */   }
/*  59:    */   
/*  60:    */   @NotNull
/*  61:    */   public Self withoutSdk()
/*  62:    */   {
/*  63: 64 */     this.a = true; JpsDependenciesEnumerator 
/*  64: 65 */       tmp9_6 = self();
/*  65: 65 */     if (tmp9_6 == null) {
/*  66: 65 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "withoutSdk" }));
/*  67:    */     }
/*  68: 65 */     return tmp9_6;
/*  69:    */   }
/*  70:    */   
/*  71:    */   @NotNull
/*  72:    */   public Self withoutModuleSourceEntries()
/*  73:    */   {
/*  74: 71 */     this.c = true; JpsDependenciesEnumerator 
/*  75: 72 */       tmp9_6 = self();
/*  76: 72 */     if (tmp9_6 == null) {
/*  77: 72 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "withoutModuleSourceEntries" }));
/*  78:    */     }
/*  79: 72 */     return tmp9_6;
/*  80:    */   }
/*  81:    */   
/*  82:    */   @NotNull
/*  83:    */   public Self satisfying(@NotNull Condition<JpsDependencyElement> paramCondition)
/*  84:    */   {
/*  85: 78 */     if (paramCondition == null) {
/*  86: 78 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "satisfying" }));
/*  87:    */     }
/*  88: 78 */     this.d = paramCondition; JpsDependenciesEnumerator 
/*  89: 79 */       tmp49_46 = self();
/*  90: 79 */     if (tmp49_46 == null) {
/*  91: 79 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "satisfying" }));
/*  92:    */     }
/*  93: 79 */     return tmp49_46;
/*  94:    */   }
/*  95:    */   
/*  96:    */   @NotNull
/*  97:    */   public Self recursively()
/*  98:    */   {
/*  99: 85 */     this.myRecursively = true; JpsDependenciesEnumerator 
/* 100: 86 */       tmp9_6 = self();
/* 101: 86 */     if (tmp9_6 == null) {
/* 102: 86 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "recursively" }));
/* 103:    */     }
/* 104: 86 */     return tmp9_6;
/* 105:    */   }
/* 106:    */   
/* 107:    */   protected abstract Self self();
/* 108:    */   
/* 109:    */   @NotNull
/* 110:    */   public Set<JpsModule> getModules()
/* 111:    */   {
/* 112: 94 */     LinkedHashSet localLinkedHashSet = new LinkedHashSet();
/* 113: 95 */     processModules(new CollectConsumer(localLinkedHashSet)); LinkedHashSet 
/* 114: 96 */       tmp21_20 = localLinkedHashSet;
/* 115: 96 */     if (tmp21_20 == null) {
/* 116: 96 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "getModules" }));
/* 117:    */     }
/* 118: 96 */     return tmp21_20;
/* 119:    */   }
/* 120:    */   
/* 121:    */   public void processModules(@NotNull final Consumer<JpsModule> paramConsumer)
/* 122:    */   {
/* 123:101 */     if (paramConsumer == null) {
/* 124:101 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "processModules" }));
/* 125:    */     }
/* 126:101 */     processDependencies(new Processor()
/* 127:    */     {
/* 128:    */       public boolean process(JpsDependencyElement paramAnonymousJpsDependencyElement)
/* 129:    */       {
/* 130:104 */         if ((JpsDependenciesEnumeratorBase.this.myRecursively) && ((paramAnonymousJpsDependencyElement instanceof JpsModuleSourceDependency)))
/* 131:    */         {
/* 132:105 */           paramConsumer.consume(paramAnonymousJpsDependencyElement.getContainingModule());
/* 133:    */         }
/* 134:107 */         else if (((!JpsDependenciesEnumeratorBase.this.myRecursively) || (!JpsDependenciesEnumeratorBase.this.shouldProcessDependenciesRecursively())) && ((paramAnonymousJpsDependencyElement instanceof JpsModuleDependency)))
/* 135:    */         {
/* 136:108 */           JpsModule localJpsModule = ((JpsModuleDependency)paramAnonymousJpsDependencyElement).getModule();
/* 137:109 */           if (localJpsModule != null) {
/* 138:110 */             paramConsumer.consume(localJpsModule);
/* 139:    */           }
/* 140:    */         }
/* 141:113 */         return true;
/* 142:    */       }
/* 143:    */     });
/* 144:    */   }
/* 145:    */   
/* 146:    */   protected boolean shouldProcessDependenciesRecursively()
/* 147:    */   {
/* 148:119 */     return true;
/* 149:    */   }
/* 150:    */   
/* 151:    */   public boolean processDependencies(Processor<JpsDependencyElement> paramProcessor)
/* 152:    */   {
/* 153:123 */     THashSet localTHashSet = new THashSet();
/* 154:124 */     for (JpsModule localJpsModule : this.myRootModules) {
/* 155:125 */       if (!a(localJpsModule, paramProcessor, localTHashSet)) {
/* 156:126 */         return false;
/* 157:    */       }
/* 158:    */     }
/* 159:129 */     return true;
/* 160:    */   }
/* 161:    */   
/* 162:    */   private boolean a(JpsModule paramJpsModule, Processor<JpsDependencyElement> paramProcessor, Set<JpsModule> paramSet)
/* 163:    */   {
/* 164:133 */     if (!paramSet.add(paramJpsModule)) {
/* 165:133 */       return true;
/* 166:    */     }
/* 167:135 */     for (JpsDependencyElement localJpsDependencyElement : paramJpsModule.getDependenciesList().getDependencies()) {
/* 168:136 */       if (((this.d == null) || (this.d.value(localJpsDependencyElement))) && 
/* 169:    */       
/* 170:138 */         ((!this.a) || (!(localJpsDependencyElement instanceof JpsSdkDependency))) && ((!this.b) || (!(localJpsDependencyElement instanceof JpsLibraryDependency))) && ((!this.c) || (!(localJpsDependencyElement instanceof JpsModuleSourceDependency))) && 
/* 171:    */         
/* 172:    */ 
/* 173:    */ 
/* 174:142 */         ((!this.myWithoutDepModules) || (
/* 175:143 */         ((this.myRecursively) || (!(localJpsDependencyElement instanceof JpsModuleDependency))) && (
/* 176:144 */         (!(localJpsDependencyElement instanceof JpsModuleSourceDependency)) || (isEnumerationRootModule(paramJpsModule))))) && 
/* 177:    */         
/* 178:    */ 
/* 179:147 */         (shouldProcess(paramJpsModule, localJpsDependencyElement))) {
/* 180:151 */         if ((localJpsDependencyElement instanceof JpsModuleDependency))
/* 181:    */         {
/* 182:152 */           if ((this.myRecursively) && (shouldProcessDependenciesRecursively()))
/* 183:    */           {
/* 184:153 */             JpsModule localJpsModule = ((JpsModuleDependency)localJpsDependencyElement).getModule();
/* 185:154 */             if (localJpsModule != null)
/* 186:    */             {
/* 187:155 */               a(localJpsModule, paramProcessor, paramSet);
/* 188:156 */               continue;
/* 189:    */             }
/* 190:    */           }
/* 191:159 */           if (this.myWithoutDepModules) {}
/* 192:    */         }
/* 193:162 */         else if (!paramProcessor.process(localJpsDependencyElement))
/* 194:    */         {
/* 195:163 */           return false;
/* 196:    */         }
/* 197:    */       }
/* 198:    */     }
/* 199:167 */     return true;
/* 200:    */   }
/* 201:    */   
/* 202:    */   protected boolean shouldProcess(JpsModule paramJpsModule, JpsDependencyElement paramJpsDependencyElement)
/* 203:    */   {
/* 204:171 */     return true;
/* 205:    */   }
/* 206:    */   
/* 207:    */   public boolean isEnumerationRootModule(JpsModule paramJpsModule)
/* 208:    */   {
/* 209:175 */     return this.myRootModules.contains(paramJpsModule);
/* 210:    */   }
/* 211:    */   
/* 212:    */   @NotNull
/* 213:    */   public Set<JpsLibrary> getLibraries()
/* 214:    */   {
/* 215:181 */     LinkedHashSet localLinkedHashSet = new LinkedHashSet();
/* 216:182 */     processLibraries(new CollectConsumer(localLinkedHashSet)); LinkedHashSet 
/* 217:183 */       tmp21_20 = localLinkedHashSet;
/* 218:183 */     if (tmp21_20 == null) {
/* 219:183 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/jps/model/module/impl/JpsDependenciesEnumeratorBase", "getLibraries" }));
/* 220:    */     }
/* 221:183 */     return tmp21_20;
/* 222:    */   }
/* 223:    */   
/* 224:    */   public void processLibraries(final Consumer<JpsLibrary> paramConsumer)
/* 225:    */   {
/* 226:187 */     processDependencies(new Processor()
/* 227:    */     {
/* 228:    */       public boolean process(JpsDependencyElement paramAnonymousJpsDependencyElement)
/* 229:    */       {
/* 230:190 */         if ((paramAnonymousJpsDependencyElement instanceof JpsLibraryDependency))
/* 231:    */         {
/* 232:191 */           JpsLibrary localJpsLibrary = ((JpsLibraryDependency)paramAnonymousJpsDependencyElement).getLibrary();
/* 233:192 */           if (localJpsLibrary != null) {
/* 234:193 */             paramConsumer.consume(localJpsLibrary);
/* 235:    */           }
/* 236:    */         }
/* 237:196 */         return true;
/* 238:    */       }
/* 239:    */     });
/* 240:    */   }
/* 241:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.jps.model.module.impl.JpsDependenciesEnumeratorBase

 * JD-Core Version:    0.7.0.1

 */